﻿@model Aga.GestionDeArchivos.Web.Models.Roles.ActionsModel
@{
    ViewBag.Title = "Editar Actiones";
    Layout = "~/Views/Shared/_InternalLayout.cshtml";
}

@section Scripts {

<script type="text/javascript">
    $(document).ready(function(){ 

        $( "#accordion" ).accordion({ collapsible: true });
    
    });
</script>

}

<div id="content">
    <table width="100%" border="0" cellpadding="0" cellspacing="0" class="box-style1">
        <tr>
            <td id="box2">
                <h2>
                    Editar Acciones - Rol: <span>@Html.Encode(Model.RoleName)</span></h2>
                @using (Html.BeginForm())
                {
                    @Html.ValidationSummary(true)
            
                    @Html.HiddenFor(model => model.RoleId)
                        
                    <div id="accordion">
                        @foreach (var group in Aga.GestionDeArchivos.Web.Models.Roles.ActionsModel.GetAllActions().GroupBy(a => a.Group))
                        {
                            <h3>
                                <a href="#">@group.Key</a></h3>
                            <div>
                                @foreach (var action in group)
                                {
                                    if (action.ActionId == 0)
                                    {
                                        continue;
                                    }
                                    else if (Model.Actions.Any(a => a.ActionId.Equals(action.ActionId)))
                                    {
                                    @Html.CheckBox("chk_" + action.ActionId, true)
                                    @action.Name<br />
                                    }
                                    else
                                    {
                                    @Html.CheckBox("chk_" + action.ActionId) 
                                    @action.Name<br />
                                    }
                                }
                            </div>

                        }
                    </div>
                    <p class="buttons">
                        @Html.ActionLink("Cancelar", "Index", null,  new { @class = "cancel" })
                        <input type="submit" value="Guardar Cambios"/>
                    </p>
                }
            </td>
        </tr>
    </table>
</div>
